﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telecom.Data;
using Telecom.Service;
using TelecomGis.Helper.Control;

namespace TelecomGis.Controllers
{
    public class KhaosatLDController : ContronllerBase
    {

        private readonly loaiBanDoSer _loaiBanDoSer = new loaiBanDoSer();
        private readonly vnptSiteSer _vnptSiteSer = new vnptSiteSer();
        private readonly loaiSiteSer _loaiSiteSer = new loaiSiteSer();
        private readonly dauNoiTbSer _dauNoiTbSer = new dauNoiTbSer();
        private readonly quanhuyenPhuongXaSer _quanhuyenPhuongXaSer = new quanhuyenPhuongXaSer();

        //
        // GET: /KhaosatLD/

        public ActionResult KhaosatLD()
        {
            return PartialView("_KhaosatLD");
        }

        public string ViewSiteOnMaps(string loaiSite)
        {
            var _listEntity = _vnptSiteSer.ViewVnptSiteOnmaps_ks(loaiSite);

            return JsonConvert.SerializeObject(_listEntity, Formatting.Indented,
                              new JsonSerializerSettings
                              {
                                  ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                              });
        }

        public ActionResult ViewThueBaoOnVnptSite_KS(int vnptSiteid)
        {
            var vnptSite = _dauNoiTbSer.getlistBySiteid(vnptSiteid);

            if (vnptSite.Count() == 0)
            {
                DAUNOI_THIETBI _entity = new DAUNOI_THIETBI();
                return PartialView("_ViewThueBaoOnVnptSite_KS", _entity);
                
            }
            else
            {
                var entityFirst = vnptSite.First();
                return PartialView("_ViewThueBaoOnVnptSite_KS", entityFirst);
            }

            
        }

    }
}
